package com.leyou.page.controller;

import com.leyou.page.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;

@Controller
public class PageController {


    @Autowired
    private PageService pageService;
//    /item/187.html
    @GetMapping("/item/{id}.html")
    public String pageDetail(Model model, @PathVariable("id") Long id){ //从url路径中取值一定要使用一个注解@PathVariable
        Map map = pageService.buildDataBySpuId(id);
        model.addAllAttributes(map);
        return "item";
    }

}
